﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using agvcsimulator.GUI;
using agvcsimulator.Module;

using agvcontroller.Common;
using agvcontroller.Common.DataBase;

namespace agvcsimulator
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        CVehicleSimDic VehicleSimDic;
        CTerminalSimDic TerminalSimDic;
        CChargerSimDic ChargerSimDic;

        public MainWindow()
        {
            InitializeComponent();

            VehicleSimDic = CVehicleSimDic.getInstance();
            TerminalSimDic = CTerminalSimDic.getInstance();
            ChargerSimDic = CChargerSimDic.getInstance();

            RegisterEvent();
        }

        void RegisterEvent()
        {
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            InitModule();
        }

        int InitModule()
        {
            TabItem item;

            UCVehicleSim ucVehicleSim;
            foreach (KeyValuePair<int, CVehicleSim> vehicleSim in VehicleSimDic)
            {
                ucVehicleSim = new UCVehicleSim(vehicleSim.Value);

                item = new TabItem();
                item.Header = vehicleSim.Value.Name;
                item.Content = ucVehicleSim;
                tabSimulator.Items.Add(item);
            }

            UCTerminalSim ucTerminalSim;
            foreach (KeyValuePair<int, CTerminalSim> terminalSim in TerminalSimDic)
            {
                ucTerminalSim = new UCTerminalSim(terminalSim.Value);
                item = new TabItem();
                item.Header = terminalSim.Value.Name;
                item.Content = ucTerminalSim;
                tabSimulator.Items.Add(item);
            }

            UCChargerSim ucChargerSim;
            foreach (KeyValuePair<int, CChargerSim> chargerSim in ChargerSimDic)
            {
                ucChargerSim = new UCChargerSim(chargerSim.Value);
                item = new TabItem();
                item.Header = chargerSim.Value.Name;
                item.Content = ucChargerSim;
                tabSimulator.Items.Add(item);
            }
            return CReturnCode.SUCCESS;
        }
    }
}
